﻿
using System.ServiceModel;
using System;
namespace NLite.Messaging
{
    /// <summary>
    /// 发布者接口
    /// </summary>
    /// <remarks>采用设计模式中的观察者模式(发布者订阅者）模式，该接口担当了抽象发布者角色</remarks>
    [Contract]
    [ServiceContract(CallbackContract = typeof(IObserverHandler<IMessage>))]
    [ServiceKnownType(typeof(Message))]
    //[ServiceKnownType(typeof(Message<>))]
    public interface IPublisher:IDisposable
    {
        /// <summary>
        /// 发布消息
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="msg">消息</param>
        [OperationContract]
        void Publish(object sender, IMessage msg);

        //// <summary>
        ///// 发布消息
        ///// </summary>
        ///// <param name="sender">sender</param>
        ///// <param name="msg">消息</param>
        //[OperationContract]
        //void Publish<TResult>(object sender, IMessage msg,Action<TResult> callback);
    }

    
}
